package io.renren.modules.sp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.constant.Constant;
import io.renren.modules.sp.dao.SpBaseMatchItemDao;
import io.renren.modules.sp.dto.SpBaseMatchItemDTO;
import io.renren.modules.sp.entity.SpBaseMatchItemEntity;
import io.renren.modules.sp.service.SpBaseMatchItemService;
import io.renren.modules.security.user.SecurityUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 赛项
 *
 * @author whc 15953295779@126.com
 * @since 3.0 2023-04-21
 */
@Service
public class SpBaseMatchItemServiceImpl extends CrudServiceImpl<SpBaseMatchItemDao, SpBaseMatchItemEntity, SpBaseMatchItemDTO> implements SpBaseMatchItemService {

    @Override
    public QueryWrapper<SpBaseMatchItemEntity> getWrapper(Map<String, Object> params){
        QueryWrapper<SpBaseMatchItemEntity> wrapper = new QueryWrapper<>();

        String itemName = (String)params.get("itemName");
        wrapper.eq(StringUtils.isNotBlank(itemName), "item_name", itemName);
        String itemClassify = (String)params.get("itemClassify");
        wrapper.eq(StringUtils.isNotBlank(itemClassify), "item_classify", itemClassify);
        wrapper.orderByAsc("sort");
        return wrapper;
    }

    @Override
    public List<SpBaseMatchItemEntity> listByItemId(Long matchId) {
        return baseDao.listByItemId(matchId);
    }

    @Override
    public List<SpBaseMatchItemEntity> listAll(Long matchId) {
        return baseDao.listAll(matchId);
    }


}